package org.vaadinpa.logic;

import org.vaadinpa.Conf;
import org.vaadinpa.logic.commands.TickCommand;

public class TickThread extends Thread {

	@Override
	public void run() {
		setName("VaadinPA tick thread");
		final TickCommand tick = new TickCommand();

		try {

			while (true) {
				sleep(Conf.TICK_LENGTH_SECONDS * 1000);

				// keep timer on track by deferring ticks
				new Thread("Tick executor thread") {
					@Override
					public void run() {
						CommandHandler.handle(tick);
					};
				}.start();
			}

		} catch (InterruptedException CONTINUE) {
			// let thread die
		}

	}
}
